import { get, post, put, del } from '@/utils/request'
import type { ServiceRecord, ServiceRecordParams } from '@/types/service-record'
import type { Result, PageResult } from '@/types/common'

// 获取服务记录列表
export function getServiceRecordList(params: ServiceRecordParams): Promise<Result<PageResult<ServiceRecord>>> {
  return get<Result<PageResult<ServiceRecord>>>('/serviceRecord/list', params)
}

// 获取服务记录详情
export function getServiceRecordDetail(id: number): Promise<Result<ServiceRecord>> {
  return get<Result<ServiceRecord>>(`/serviceRecord/${id}`)
}

// 添加服务记录
export function addServiceRecord(data: Partial<ServiceRecord>): Promise<Result<null>> {
  return post<Result<null>>('/serviceRecord/add', data)
}

// 更新服务记录
export function updateServiceRecord(data: Partial<ServiceRecord>): Promise<Result<null>> {
  return put<Result<null>>('/serviceRecord/update', data)
}

// 删除服务记录
export function deleteServiceRecord(id: number): Promise<Result<null>> {
  return del<Result<null>>(`/serviceRecord/delete/${id}`)
}
